package com.java.al.swing;

import java.util.concurrent.TimeUnit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

/**
 * Swing 最正宗的写法!不会出现线程冲突和死锁!
 * 
 *
 */

public class SubmitSwingProgrem extends JFrame {
	private JLabel label;
	public SubmitSwingProgrem(){
		super("Hello Swing!");
		label = new JLabel("A Label!");
		add( label );
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(300,100);
		setVisible(true);
	}
	static SubmitSwingProgrem ssp;
	public static void main(String[] args) throws InterruptedException{
		SwingUtilities.invokeLater( new Runnable(){ //调用Swing应使用这种方式!
			public void run(){
				ssp = new SubmitSwingProgrem();
			}
		});
		TimeUnit.SECONDS.sleep(1);
		SwingUtilities.invokeLater( new Runnable(){
			public void run(){
				ssp.label.setText( "Hey! This is Defferent!" );
			}
		});
	}
}
